package com.kefu.call.vo;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;

import com.kefu.call.model.ActivityInventoryInfo;
import com.kefu.call.model.ContactPlan;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractUpdateVo;

import cn.hutool.core.util.IdUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author francis
 * @date 2021/05/22
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "处理活动清单")
public class ActivityInventoryInfoHandleVo extends AbstractUpdateVo<ActivityInventoryInfo,String> {


	@NotEmpty
    @ApiModelProperty(value = "主键")
    private String inventoryId;
   
    @ApiModelProperty(value = "清单状态",example="1",allowableValues="1,2",notes="1 未完成，2已完成")
    private Integer inventoryStatus;
    @ApiModelProperty(value = "意向状态",example="0",allowableValues="0,1,2,3,4",notes="0 无，1 无效电话，2无意向，3 意向，4已成交")
    private Integer intentionStatus;
    @Size(max = 32)
    @ApiModelProperty(value = "客户ID")
    private String customerId;
    @Size(max = 32)
    @ApiModelProperty(value = "客户名称")
    private String customerName;
    @ApiModelProperty(value = "客户电话")
    private String customerPhone;
    @ApiModelProperty(value = "预约时间",notes="预约时间在这里主要是查看用的，具体提醒时间看联系计划")
    private Long reserveTime;
    @Size(max = 32)
    @ApiModelProperty(value = "联系计划ID")
    private String planId;
    @Size(max = 200)
    @ApiModelProperty(value = "清单备注")
    private String inventoryDesp;

    @ApiModelProperty(value = "联系计划开始时间")
    private long planStartTime;
    @ApiModelProperty(value = "联系计划结束时间" ,notes="联系计划的开始结束时间与预约时间有一定的关系，在前端处理，")
    private long planEndTime;
    
    
    @Override
    public ActivityInventoryInfo convert() {
        ActivityInventoryInfo info = new ActivityInventoryInfo();
       
        info.setInventoryStatus(inventoryStatus);
        info.setIntentionStatus(intentionStatus);
        info.setCustomerId(customerId);
        info.setCustomerName(customerName);
        info.setReserveTime(reserveTime);
        info.setPlanId(planId);
        info.setInventoryDesp(inventoryDesp);
        KefuContext context = KefuContext.getKefuContext();
        info.setInventoryId(inventoryId);
        info.setUpdateTime(context.getNow());
        info.setUpdateUser(context.getUserId());
        return info;
	}
    
    public ContactPlan convertContactPlan(ActivityInventoryInfo inventory) {
    	 ContactPlan info = new ContactPlan();
 	    info.setDataStatus(1);
 	    info.setPlanName(inventory.getInventoryName());
 	    info.setSubscribeTime(planStartTime);
 	    info.setPlanStatus(1);//启用
 	    info.setPlanType(1);//活动外呼计划
 	    info.setCustomerId(customerId);
 	    info.setCustomerName(customerName);
 	    info.setCustomerPhone(customerPhone);
 	    info.setPlanDesp(inventoryDesp);
         KefuContext context = KefuContext.getKefuContext();
 		info.setPlanId(IdUtil.simpleUUID());
 	    info.setCreateTime(context.getNow());
 	    info.setCreateUser(context.getUserId());
 	    info.setUpdateTime(context.getNow());
 	    info.setUpdateUser(context.getUserId());
 	    info.setTenantId(context.getTenantId());
 	    
 	    inventory.setPlanId(info.getPlanId());
    	return info;
    }
}